package com.fau.fm.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

import com.fau.fm.util.SystemConfig;

/**
 * @desc 绩效薪资设置Entity
 * @author dangjh
 * @datetime 2014年11月20日,上午11:16:24
 */
@Entity
@Table(name = "medical_performance_salary")
public class MedicalPerformanceSalary implements Serializable, JSONAware {

	private static final long serialVersionUID = -7652836754245025408L;

	private String id;
	
	private String deptType;
	private Integer number;
	private BigDecimal money;
	private String isLeader;
	private String eid;
	private Date createTime = new Date();
	private Date updateTime = new Date();
	private String medicineId;
	private String hospitalId;
	
	private String medicineName;
	private String deptTypeName;
	private Date startTime;
	private Date endTime;
	
	private String stime;
	private String etime;
	
	public MedicalPerformanceSalary() {
		
	}
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "dept_type", length = 5)
	public String getDeptType() {
		return deptType;
	}

	public void setDeptType(String deptType) {
		this.deptType = deptType;
	}

	@Column(name = "number", length = 11)
	public Integer getNumber() {
		return number;
	}

	public void setNumber(Integer number) {
		this.number = number;
	}

	@Column(name = "money", length = 20)
	public BigDecimal getMoney() {
		return money;
	}

	public void setMoney(BigDecimal money) {
		this.money = money;
	}

	@Column(name = "is_leader", length = 5)
	public String getIsLeader() {
		return isLeader;
	}

	public void setIsLeader(String isLeader) {
		this.isLeader = isLeader;
	}

	@Column(name = "eid", length = 32)
	public String getEid() {
		return eid;
	}

	public void setEid(String eid) {
		this.eid = eid;
	}
	
	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "update_time")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "medicine_id", length = 32)
	public String getMedicineId() {
		return medicineId;
	}

	public void setMedicineId(String medicineId) {
		this.medicineId = medicineId;
	}

	@Transient
	public String getMedicineName() {
		return medicineName;
	}

	public void setMedicineName(String medicineName) {
		this.medicineName = medicineName;
	}

	@Transient
	public String getDeptTypeName() {
		return deptTypeName;
	}

	public void setDeptTypeName(String deptTypeName) {
		this.deptTypeName = deptTypeName;
	}

	@Transient
	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	@Transient
	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	@Transient
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}

	@Transient
	public String getStime() {
		return stime;
	}

	public void setStime(String stime) {
		this.stime = stime;
	}

	@Transient
	public String getEtime() {
		return etime;
	}

	public void setEtime(String etime) {
		this.etime = etime;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("id", id);
		obj.put("medicineName", medicineName);
		obj.put("medicineId", medicineId);
		obj.put("deptType", deptType);
		obj.put("isLeader", isLeader);
		obj.put("deptTypeName", deptTypeName);
		if(SystemConfig.GROUP_EMPLOYEE.equals(isLeader)) {
			obj.put("office", "组员");
		} else if(SystemConfig.GROUP_LEADER.equals(isLeader)) {
			obj.put("office", "组长");
		}
		obj.put("number", number);
		obj.put("money", money);
		obj.put("createTime", DateFormatUtils.format(createTime, "yyyy-MM-dd HH:mm:ss"));
		obj.put("updateTime", DateFormatUtils.format(updateTime, "yyyy-MM-dd HH:mm:ss"));
		if(null != startTime) {
			obj.put("startTime", DateFormatUtils.format(startTime, "yyyy-MM-dd"));
		}
		if(null != endTime) {
			obj.put("endTime", DateFormatUtils.format(endTime, "yyyy-MM-dd"));
		}
		obj.put("hospitalId", hospitalId);
		return obj.toJSONString();
	}

}
